<?php


   $pdo = new PDO("mysql:host=localhost;dbname=hospital","root","tailiyan88"); 

    $json_string = file_get_contents("a.json");
    
    $obj=json_decode($json_string,true);
	if (!is_array($obj)) die('no successful');
	foreach($obj as $v){
		echo $v["key"].$v["label"]."<br>";
		
		//$pdo->exec("insert into areas(`key`,`lable`) values('".$v['key']."','".$v['label']."')");
		if(!empty($v["children"])&& is_array($v["children"]))
		{
		 listAll($v["children"],"  --",$pdo);
		}
	}
	
	function listAll($data,$str,$con){
			foreach($data as $c)
			{
				echo $str.$c["key"].$c["label"]."<br>";
			  // $con->exec("insert into areas(`key`,`lable`) values('".$c['key']."','".$c['label']."')");
				if(!empty($c["children"]) && is_array($c["children"]))
		        {
				 listAll($c["children"],"    --||-",$con);
				}
			}
		
		
	}